package com.neuedu.helloworld.order;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;

import com.neuedu.helloworld.R;
import com.neuedu.helloworld.ZxingUtils;

public class OrderDetailActivity extends AppCompatActivity implements View.OnClickListener {


    private ImageView ivQrCode;
    private Button btnGenerator;
    private EditText etInputCodeData;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_order_detail);


        ivQrCode = findViewById(R.id.ivQrCode);
        etInputCodeData = findViewById(R.id.etInputCodeData);
        btnGenerator = findViewById(R.id.btnGenerator);


        btnGenerator.setOnClickListener(this);


    }

    @Override
    public void onClick(View v) {
        //1 生成二维码，
//        二进制的位图数据

//        String msg = "http://www.baidu.com";
        String msg = "null";
        String intput = etInputCodeData.getText().toString();
        if(intput!= null && intput.length()>0){
            msg   = intput;
        }

        
        //在内存中生成 位图

        Bitmap bm =  ZxingUtils.createQRImage(msg , 400,400);  // ??


        //2 设置到ImageView的位置渲染
        ivQrCode.setImageBitmap(bm);
    }
}